package com.platform.modules.wallet.domain;

import cn.hutool.crypto.SecureUtil;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.platform.common.web.domain.BaseEntity;
import com.platform.modules.wallet.enums.AccountStatusEnum;
import com.platform.modules.wallet.enums.AccountTypeEnum;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.Date;

@Data
@TableName("wallet_account")
@Accessors(chain = true)
public class WalletAccount extends Model<WalletAccount> {
    /**
     * 主键
     */
    @TableId
    private Long id;

    private Long otherId;

    private Integer amount;
    private Integer balance;
    private AccountTypeEnum type;

    private AccountStatusEnum status;

    private Date createTime;
    private Date successTime;
    private Date createDate;
    private Long userId;
    private String privateKey;

    public String getKey(){
        StringBuffer sb=new StringBuffer();
        sb.append(userId);
        sb.append(otherId);
        sb.append(amount);
        sb.append(status.getCode());
        sb.append(type.getCode());
        sb.append(createDate.getTime());
        sb.append(createTime.getTime());
        return SecureUtil.md5(sb.toString());
    }
}
